<?php 

//控制基类
class Controller extends Smarty
{

    public function __construct()
    {
        //Smarty配置
        $this->setTemplateDir('./views') //模版
            ->setCompileDir('./runtime/views_c')//编译
            ->setConfigDir('./configs')//配置
            ->setCacheDir('./runtime/caches');//缓存
        $this->left_delimiter = LEFT_D;
        $this->right_delimiter = RIGHT_D;
        $this->caching = CACHING;//开启缓存
        $this->cache_lifetime = CACHE_LIFETIME;//配置缓存的生效时间
    }

    //跳转提示
    public function redirect($massage, $url=null)
    {
        echo "<script>alert('{$massage}')</script>";
        if (empty($url)) {
            echo "<script>history.back()</script>";
        } else {
            echo "<script>location.href='{$url}'</script>";
        }
        
    }

    public function __call($fun, $params)
    {
        header("HTTP/1.0 404 not found");
        header("Status:404 not found");//兼容IE
        echo "<h1>404 NOT FOUND 来自于基类</h1>";
        exit;
    }
}

